Skip to content

feat(android): publish clickable, focusable, long-clickable and scrollable on raw snapshot nodes - #4633

Merged
thymikee merged 9 commits into
callstack:mainfrom
dannyhw:snapshot-node-interaction-flags
Nov 17, 2026
Merged

thymikee merged 9 commits into
callstack:mainfrom
dannyhw:snapshot-node-interaction-flags

Conversation

@dannyhw

@dannyhw dannyhw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Raw Android snapshot nodes (snapshot --raw) publish four accessibility facts next to hittable:

  • clickable, focusable and scrollable: the reader already parsed these and dropped them at the projection.
  • longClickable: the snapshot helper now writes long-clickable with both answers, so a capture served by an older helper reports nothing instead of false.

Default and -i snapshots are unchanged: the four facts travel in AndroidPassiveNodeFacts and the regular projection leaves them out, so the builder gains no lines and default snapshot --json output stays as it was.

Why

hittable is true for a node that is clickable, focusable or focused. That is the right question for driving a screen, and it hides a difference an accessibility check needs: a node a screen reader can land on but cannot activate is hittable, and so is one it can activate.

My case is a suite that tests native controls hosted in a React Native app (Compose inside React Native views). It asserts things like "the node carrying the control's name is the clickable one" and "a control with a long-press menu offers a long click". Today those few assertions need adb shell uiautomator dump, which cannot run while the helper session holds the accessibility connection, so they live in a separate pass after the suite. Raw captures are enough for that.

Review points

  • Publication: raw only, as suggested. If you would rather have them in the default output, removing the one destructure in serializeRegularSnapshotPresentationNode is the whole change.
  • Comments: snapshot-private-evidence.ts now says only raw Android nodes serialize clickable; snapshot-freshness/android.ts no longer says the helper writes no long-clickable; the AndroidPassiveNodeFacts comment says which facts the regular projection leaves out.
  • clickableByNodeIndex: still needed. Maestro's clickable-first ordering reads it on default snapshots, whose nodes do not carry clickable. The new default-route test shows the map populated while the nodes carry none of the four keys.
  • longClickable is a passive fact with no conditional spread.
  • SELECTOR_DIGEST_NODE_FIELDS: the four keys are added. An explicit false carries meaning here, as it does for checked; they cost nothing on default nodes, and a --raw get attrs keeps them. Say if you would rather leave them out.
  • Docs: snapshots.md has one bullet per field and says absent means unavailable.
  • Tests: a non-raw case with one clickable row and one fully clipped row; the helper's Java suite asserts long-clickable true and false.

Checks

  • pnpm check:quick passes.
  • Unit tests for the daemon, contracts, capture-kit, platform-android and maestro packages pass (8,436 tests in 972 files). The helper's Java suite passes inside build:android-snapshot-helper.
  • pnpm check:affected --run: format, lint and typecheck pass. On my machine the layering step stops in two tests that make a commit in a temporary repo, because my git config signs commits and has no key for them; the steps after it did not run locally.

The Coverage failure on 4451103

Run 44093694330 failed on one test out of 20,774, in a package this change does not touch:

FAIL  unit-core  packages/proxy/src/daemon-proxy-transfer.test.ts > an explicit operator cap settles an ignored custom request and reaches its bounded signal
Error: socket hang up

No threshold failed. The same file passes locally on this branch three times in a row (21 of 21 each). I cannot re-run the job from a fork, so the head now carries an empty commit to run the checks again.

Device evidence

  • Device: Android emulator sdk_gphone64_arm64 (Pixel 9 profile), API 35
  • Source: af7dd7344723ecf29f87b81f4fceeca6650a8ec8. The head adds two commits after it: one that only changes a code comment, and an empty one to re-run the checks.
  • package.json version: 0.21.39-dev
  • App: the example app of react-native-nitro-ui (nitroui.example), ContextMenu screen

Build

pnpm build:android
pnpm build
pnpm clean:daemon

Captures with the rebuilt helper

agent-device open nitroui.example --platform android --serial <serial> --session adpr
agent-device snapshot --json --raw --platform android --serial <serial> --session adpr
agent-device snapshot -i --json --platform android --serial <serial> --session adpr

The first capture of the session installed the helper (installReason: "missing"). The two captures below then reused it.

snapshot --json --raw:

"androidSnapshot": { "backend": "android-helper", "helperVersion": "0.21.39-dev", "helperApiVersion": "2", "helperTransport": "persistent-session", "installReason": "current" }

141 nodes. clickable, focusable, longClickable and scrollable are present on all 141. longClickable is true on 1 node and false on 140.

{"ref":"e87","identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","clickable":true,"focusable":true,"longClickable":false,"scrollable":false,"hittable":true}
{"ref":"e104","identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","clickable":false,"focusable":true,"longClickable":true,"scrollable":false,"hittable":true}
{"ref":"e89","identifier":"ctx-scroll","type":"android.widget.ScrollView","clickable":false,"focusable":true,"longClickable":false,"scrollable":true,"hittable":true}
  • clickable true: ctx-reset
  • long-clickable true: ctx-accessible
  • long-clickable false: ctx-reset
  • scrollable true: ctx-scroll

snapshot -i --json, with the same nodes:

"androidSnapshot": { "backend": "android-helper", "helperVersion": "0.21.39-dev", "helperApiVersion": "2", "helperTransport": "persistent-session", "installReason": "current" }

42 nodes. None of the 42 has any of the four keys.

{"ref":"e16","identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","hittable":true}
{"ref":"e29","identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","hittable":true}
{"ref":"e18","identifier":"ctx-scroll","type":"android.widget.ScrollView","hittable":true}

(Nodes trimmed to ref, identifier, label, type, the four facts and hittable.)

Capture with the released 0.21.37 helper

The CLI has no option for choosing the helper artifact, and its install policy (missing-or-outdated) upgrades an installed 0.21.37 helper to the bundled one before it captures. So this capture calls the host through the option the code provides, snapshotAndroid(device, { helperArtifact }) in packages/platform-android/src/snapshot.ts, with the artifact set to the released v0.21.37 helper (its manifest and APK, sha256 bfb470a1cc168e823766fedc62bf052b60b0fafa4527033e6fc7c709f8d1f317). The rebuilt helper was uninstalled first, so the host installed 0.21.37.

await import('<checkout>/src/platform-runtime-android-adb-host.ts');
const { snapshotAndroid } = await import('<checkout>/packages/platform-android/src/snapshot.ts');
const { parseAndroidSnapshotHelperManifest } = await import(
  '<checkout>/packages/platform-android/src/snapshot-helper-artifact.ts'
);
const { withCommandHost } = await import('<checkout>/packages/host-kit/src/internal/exec.ts');
const manifest = parseAndroidSnapshotHelperManifest(
  JSON.parse(readFileSync('<v0.21.37 helper dist>/agent-device-android-snapshot-helper-0.21.37.manifest.json', 'utf8')),
);
const helperArtifact = { apkPath: '<v0.21.37 helper dist>/' + manifest.assetName, manifest };
const device = { platform: 'android', id: '<serial>', name: '<serial>', kind: 'emulator', booted: true };
const result = await withCommandHost({ host: { env: { ...process.env }, cwd: process.cwd() }, requestEnv: undefined }, () =>
  snapshotAndroid(device, { helperArtifact, raw: true }),
);

After the run, the device reports versionCode=21037, versionName=0.21.37. The process exited 0 and wrote nothing to stderr.

"androidSnapshot": { "backend": "android-helper", "helperVersion": "0.21.37", "helperApiVersion": "2", "helperTransport": "persistent-session", "installReason": "missing" }

141 nodes. clickable, focusable and scrollable are present on all 141. longClickable is absent from all 141: the key is missing, not false.

{"identifier":"ctx-reset","label":"Reset the counters","type":"android.view.ViewGroup","clickable":true,"focusable":true,"scrollable":false,"hittable":true}
{"identifier":"ctx-accessible","label":"Message from Grace","type":"android.view.ViewGroup","clickable":false,"focusable":true,"scrollable":false,"hittable":true}
{"identifier":"ctx-scroll","type":"android.widget.ScrollView","clickable":false,"focusable":true,"scrollable":true,"hittable":true}

…lable on snapshot nodes

A snapshot node carries hittable, which is true for a node that is clickable,
focusable or focused. A reader that audits what an accessibility service is
offered needs those apart: a node a screen reader can land on but cannot
activate is hittable, and so is one it can activate.

The Android reader already parses clickable, focusable and scrollable; this
publishes them on the node. The snapshot helper now writes long-clickable,
with both answers so a capture from an older helper is not read as a node
that offers no long click.
@thymikee

Copy link
Copy Markdown
Member

The code change at d56b15a looks reasonable, but it has no live device evidence yet, so it needs one recorded run before merge.

The PR changes the device-facing helper (a new XML attribute on every node) and the Android snapshot projection. The PR body has only three pasted node lines from an unnamed build, and its State section says the full check:affected, a helper-suite test and docs are not done. Nothing shows that the rebuilt helper serializes long-clickable on a device, that the default snapshot -i --json route publishes the four fields, or that an older installed helper degrades cleanly. Please run pnpm build:android, pnpm build and pnpm clean:daemon, then on an API 35 emulator capture snapshot -i --json and snapshot --json --raw at d56b15a (see AccessibilityTreeXml.java:64). Record the device, the source SHA, androidSnapshot.backend: android-helper with helperVersion equal to package.json, and one node each for clickable true, long-clickable true and false, and scrollable true. Add one capture with the previously installed helper APK that shows longClickable absent (not false) and no error.

The four new keys are also written as explicit booleans on every node in the default projection, not only raw, at ui-hierarchy-builder.ts:481. Is that intended? snapshot --json and MCP/AI-SDK results gain 3-4 mostly-false keys per node, which is tens of KB on a 500-node screen. Could the four facts be published only from the raw projection, carried through AndroidPassiveNodeFacts so the builder gains no lines, which keeps default snapshot --json byte-identical? If you want them by default, publishing only the true values (omitting false, as heading does) keeps absent cheap. This needs a maintainer decision first, recorded by amending the "deliberately kept outside SnapshotNode" rule in snapshot-private-evidence.ts. After that, please check whether Android's private clickableByNodeIndex map is still needed once the node carries clickable.

Not blocking, and fine to take or leave: longClickable is a pure passive fact, so it fits in AndroidPassiveNodeFacts (spread at ui-hierarchy-builder.ts:473) instead of a new top-level field and a conditional spread, which is unneeded because undefined keys already drop out; two comments are now false (android.ts:48 says the helper serializes no long-clickable, and snapshot-private-evidence.ts:5-8 says clickability is never serialized into the snapshot contract); once the publication choice is made, snapshots.md needs one bullet per published field (absent means unavailable) and SELECTOR_DIGEST_NODE_FIELDS needs a decision on the four keys, since digest-level get attrs omits them while default level carries them; and both changed tests run with { raw: true }, so a non-raw case (one clickable row, one fully clipped row) and a helper unit assertion for long-clickable true/false would cover the default route.

The failing check is oxlint . --deny-warnings on scripts/layering/package-boundaries.test.ts:1001 ("File has too many lines (1001)"). The PR does not touch scripts/, and that file has 1000 lines at the PR head and 1001 on main fce2fa6, so this failure looks unrelated to the PR. Typecheck and formatting passed. There are no conflicts. Before merge, we need the maintainer decision on default, raw-only or opt-in publication, and then the recorded helper run at the head SHA.

@dannyhw
dannyhw marked this pull request as ready for review November 17, 2026 13:14
clickable, focusable, longClickable and scrollable now travel as passive
facts, so the raw projection carries them without new builder lines and
longClickable drops out when the helper did not report it. The regular
serializer omits all four, which keeps default snapshot --json unchanged:
on a 500-node screen they would add tens of KB of mostly-false keys.
Publishing them by default is a matter of removing that omission.

A regular-projection case pins what the default route publishes for a
visible and a fully clipped row.
The private evidence comment now says raw Android nodes serialize clickable,
and the freshness signature comment no longer says the helper serializes no
long-clickable.
They are field facts whose explicit false is the signal, the rule the digest
already follows for editable and checked. A regular node carries none of
them, so the digest is unchanged there; a raw node keeps what it reported,
and the list needs no change if they are later published by default.
The helper writes long-clickable through a package-level method so its own
suite, which runs without the Android runtime, can assert true and false.
@dannyhw

dannyhw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@thymikee will add more details like snapshot etc and the suggested changes

@dannyhw dannyhw changed the title feat(android): publish clickable, focusable, long-clickable and scrollable on snapshot nodes feat(android): publish clickable, focusable, long-clickable and scrollable on raw snapshot nodes Nov 17, 2026
@thymikee

Copy link
Copy Markdown
Member

The code in 4451103 is ready: all six asks from the earlier review (#4633 (comment)) are now in this head, and the live-run evidence in the PR body covers them. Not blocking: AccessibilityTreeXmlTest.java:11 calls the appendLongClickableAttribute formatter directly, so removing the call at AccessibilityTreeXml.java:64 would keep the suite green; if the suite already has a fake AccessibilityNodeInfo, one case through the real appendNode path would close that, and you can take or leave it.

The Coverage check (run 44093694330) is still red. This PR touches packages that job runs (platform-android, daemon response-views, command-runtime snapshot-unchanged, kernel types), so it may be related. Please share the failing assertion or threshold, or re-run it if it was a flake. Once Coverage is green or explained, nothing else holds this back, and there are no conflicts.

The live run was at af7dd73, which differs from this head only by one doc comment in ui-hierarchy-node.ts, so it still applies.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee
thymikee merged commit 064f287 into callstack:main Nov 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants